<template>
  <div>
    <el-breadcrumb separator-icon="ArrowRight" style="margin: 16px">
      <el-breadcrumb-item :to="{ path: '/adminHome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>房源信息管理</el-breadcrumb-item>
      <el-breadcrumb-item>房源删除</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card style="margin: 15px; min-height: calc(100vh - 111px)">
      <div style="color: black; font-size: 20px;font-weight: bolder; text-align: center;">房源总列表</div>
      <div>
        <div style="margin: 40px 0">
          <div style="margin: 10px 0">
            <el-input v-model="search" 
                      @input="filterData"
                      clearable 
                      placeholder="请输入房屋ID号" 
                      prefix-icon="Search"
                      style="width: 20%"/>
            <el-button icon="Search" style="margin-left: 5px" type="primary" @click="filterData"></el-button>
            <el-button icon="refresh-left" style="margin-left: 10px" type="default" @click="reset"></el-button>
          </div>
        </div>
        <!--表格-->
        <el-table v-loading="loading" :data="tableData" border max-height="705" style="width: 100%">
          <el-table-column label="房源信息">
            <template #default="{ row }">
            <el-card style="width: 100%; margin-bottom: 10px;">
              <div class="common-layout">
                <el-container>
                  
                  <!-- 左侧显示图片 -->
                  <el-aside width="200px">
                    <el-image :src="row.imageUrl" fit="fill" style="width: 100%; height: 100%"></el-image>
                  </el-aside>

                  <el-container>
                    <!-- 头部显示标题及链接 -->
                    <el-header style="text-align: center;">
                      <router-link :to="{ name: 'AdminAuditionHouseDisplay', query: { houseId: row.houseId } }">
                        {{ row.title }}
                      </router-link>
                      <el-tag
                        :type="getStatusTagType(row.status)"
                        effect="dark"
                        size="medium" 
                        style="width: auto; height: 30px; position: absolute; right: 30px; top: 15%; transform: translateY(-40%); font-weight: bolder ; font-size: 14.5px; white-space: nowrap;"
                      >
                        {{ getStatusLabel(row.status) }}
                      </el-tag>
                    </el-header>
                    <!-- 房源描述 -->
                    <el-main style="margin-top: -35px;">
                      {{ row.description }}
                    </el-main>
                  </el-container>
                  
                </el-container>
              </div>
            </el-card>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="130px">
            <template #default="scope">
              <el-popconfirm title="确认删除？" @confirm="handleDelete(scope.row)">
                <template #reference>
                  <el-button icon="Delete" type="danger">删除</el-button>
                </template>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <!--分页-->
        <div style="margin: 40px 0">
          <el-pagination
              v-model:currentPage="currentPage"
              :page-size="pageSize"
              :page-sizes="[5, 10, 15]"
              :total="total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"></el-pagination>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script src="@/assets/js/HouseDelete.js"></script>